
package br.ufrn.dca.scontrol.util;

import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.Timer;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartPanel.*;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.RegularTimePeriod;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.time.TimeSeriesDataItem;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleInsets;

/**
 *
 * @author marco
 */
public class DefaultChartPanel extends JPanel{

    private TimeSeries total;
    private TimeSeries free;

    public DefaultChartPanel(int maxAge) {
        super(new BorderLayout(), true);
//
//        total = new TimeSeries("Total Memory", Millisecond.class);
//        total.setMaximumItemAge(maxAge);
//
//        free = new TimeSeries("Free Memory", Millisecond.class);
//        free.setMaximumItemAge(maxAge);
//
//        TimeSeries ts = new TimeSeries(maxAge);
//
//        TimeSeriesDataItem dItem = new TimeSeriesDataItem(, maxAge)
//        ts.
//        total.add(item)
//
//        TimeSeriesCollection dataset = new TimeSeriesCollection();
//        dataset.addSeries(total);
//        dataset.addSeries(free);
//
//        DateAxis domain = new DateAxis("Time");
//        NumberAxis range = new NumberAxis("Memory");
//        domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
//        range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
//        domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
//        range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
//
//        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
//        renderer.setSeriesPaint(0, Color.red);
//        renderer.setSeriesPaint(1, Color.green);
//        renderer.setStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL));
//
//        XYPlot plot = new XYPlot(dataset, domain, range, renderer);
//        plot.setBackgroundPaint(Color.lightGray);
//        plot.setDomainGridlinePaint(Color.white);
//        plot.setRangeGridlinePaint(Color.white);
//        plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
//
//        domain.setAutoRange(true);
//        domain.setLowerMargin(0.0);
//        domain.setUpperMargin(0.0);
//        domain.setTickLabelsVisible(true);
//
//        range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
//
//        JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true);
//        chart.setBackgroundPaint(Color.white);
//
//        ChartPanel chartPanel = new ChartPanel(chart);
//        chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),BorderFactory.createLineBorder(Color.black)));
//        chartPanel.setVisible(true);
//        add(chartPanel);
        XYSeries series = new XYSeries("Average Weight");
        series.add(20.0, 20.0);
        series.add(40.0, 25.0);
        series.add(55.0, 50.0);
        series.add(70.0, 65.0);
        XYDataset xyDataset = new XYSeriesCollection(series);
        JFreeChart chart = ChartFactory.createXYLineChart("XYLine Chart using JFreeChart", "Age", "Weight",
                xyDataset, PlotOrientation.VERTICAL, true, true, false);
        ChartFrame frame = new ChartFrame("XYLine Chart",chart);

    }
}
